package br.com.queroprestador.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import br.com.queroprestador.interfaces.EndPoint;

@SuppressWarnings("serial")
public class EndPointController extends HttpServlet {
    
	
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        String parameter = request.getParameter("endpoint");
        String className = "br.com.queroprestador.endpoint." + parameter + "EndPoint";
        
       
        try {
            @SuppressWarnings("rawtypes")
			Class cl = Class.forName(className);

            EndPoint endpoint = (EndPoint) cl.newInstance();
            endpoint.getEndPoint(request, response);

        } catch (Exception e) {
            throw new ServletException("A lógica de " + "negócios causou uma exceção", e);
        }
    }

}
